<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/2/27
  Time: 16:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>我的信息</title>

    <style>
        .left li{
            width: 100px;
            height: 40px;
            border:1px silver solid;
            text-align: center;
            line-height: 40px;
            background-color: #6c757d;
        }

        .left li:hover{
        ;background-color:rgba(13,13,14,0.4)
        }

        #jbxx li{
            height: 40px;
            line-height: 40px;
        }
    </style>
</head>
<body>
<jsp:include page="header.jsp"/>
<div style="width: 720px;margin: 0 auto;">
    <div style="padding-top: 10px;width: 60px;height: 60px;margin: 0 auto;">
        <img src="${user.avatar}" width="60px" height="60px" style="border-radius: 50%">
    </div>
    <div style="text-align: center;margin-top: 10px">${user.nickname}</div>
    <div>
        <ul class="left">
            <li onclick="jbxx(${sessionScope.user.id})">基本信息</li>
            <li onclick="wddd(${sessionScope.user.id})">我的订单</li>
        </ul>
    </div>

    <div id="right" style="width: 620px;position: relative;margin: -80px 0 0 100px;">

    </div>
</div>
<jsp:include page="footer.jsp"/>

<script>
    function jbxx(id) {
        $.ajax({
            url:"${pageContext.request.contextPath}/toMessage?id="+id,
            type:"POST",
            dataType:"JSON",
            success:function (data) {
                var str = '';
                str += '<div id="jbxx" style="text-align: center;">'+
                    '<li>用户名：'+data.userName+'</li>'+
                    '<li>昵&nbsp;称：<span id="nickname" display="">'+data.nickname+'</span><input type="hidden" value="'+data.nickname+'" id="sbd">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style="color: #1da1f2;" onclick="updatenn()" id="upnn">更改</a></li>'+
                    '<li>密&nbsp;码：<span id="password" display="">'+data.password+'</span><input type="hidden" value="'+data.password+'" id="sbc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style="color: #1da1f2;" onclick="updatepw()" id="uppw">更改</a></li>'+
                    '<li>用户等级：<c:choose><c:when test="'+${user.type < 2}+'">普通会员</c:when><c:otherwise>管理员</c:otherwise></c:choose></li>'+
                    '<li>创建时间：'+data.createTime+'</li>'+
                    '</div>';
                    $('#right').html(str);
            }
        })
    }

    function updatenn() {
        document.getElementById("nickname").style.display = "none";
        document.getElementById("sbd").type="text";
        document.getElementById("upnn").onclick = "upn()";
        alert("1")
    }

    function upn() {
        var nickname = document.getElementById("sbd").value;
        alert(nickname+"1")
        alert("sb")
            $.ajax({
                url:"${pageContext.request.contextPath}/user/updateuser?user.nickname =" + nickname,
            })
            document.getElementById("nickname").style.display = "";
            document.getElementById("sbd").type="hidden";
            alert(nickname)
    }

    function updatepw() {
        document.getElementById("password").style.display = "none";
        document.getElementById("sbc").type="text";
    }

</script>
</body>
</html>
